﻿using System;
using Plugins.UserControls;
using Utils;

namespace Plugins.Base
{
    [Serializable]
	public class EngineSettingsBase : ICopyable<EngineSettingsBase>, ICloneable<EngineSettingsBase>
    {
		#region Attributes

		protected readonly StockParametersSelectorData _stockParameters;
		protected readonly HourSelectorData _hourOptions;
		protected readonly StockSelectorData _stockSelectionOptions;

		#endregion

		#region Properties

    	public StockParametersSelectorData StockParameters
    	{
    		get { return _stockParameters; }
    	}

		public TimeSpan ForcedCloseTime
		{
			get { return _hourOptions.ForcedCloseTime; }
			set { _hourOptions.ForcedCloseTime = value; }
		}

		public TimeSpan LastOperationStart
		{
			get { return _hourOptions.LastOpen; }
			set { _hourOptions.LastOpen = value; }
		}

		public TimeSpan? Start
		{
			get { return _hourOptions.OperationStart; }
			set { _hourOptions.OperationStart = value; }
		}

		public bool StartWithOpening
		{
			get { return _hourOptions.StartWithOpening; }
			set { _hourOptions.StartWithOpening = value; }
		}

		public string SelectedStockName
		{
			get { return _stockSelectionOptions.SelectedStockName; }
			set { _stockSelectionOptions.SelectedStockName = value; }
		}

		public decimal FixedFeePerItem
		{
			get { return _stockParameters.FixedFeePerItem; }
			set { _stockParameters.FixedFeePerItem = value; }
		}

		public decimal FixedFeePerOperation
		{
			get { return _stockParameters.FixedFeePerOperation; }
			set { _stockParameters.FixedFeePerOperation = value; }
		}

		public decimal FixedReserve
		{
			get { return _stockParameters.FixedReserve; }
			set { _stockParameters.FixedReserve = value; }
		}

		public decimal PercentageFee
		{
			get { return _stockParameters.PercentageFee; }
			set { _stockParameters.PercentageFee = value; }
		}

		public decimal PercentageReserve
		{
			get { return _stockParameters.PercentageReserve; }
			set { _stockParameters.PercentageReserve = value; }
		}

		public decimal ValueMultiplier
		{
			get { return _stockParameters.ValueMultiplier; }
			set { _stockParameters.ValueMultiplier = value; }
		}

		#endregion

		#region Public Methods

		public EngineSettingsBase(HourSelectorData hourOptions, StockSelectorData stockSelectionOptions, StockParametersSelectorData stockParameters)
		{
			_hourOptions = hourOptions;
			_stockSelectionOptions = stockSelectionOptions;
			_stockParameters = stockParameters;
		}

		#endregion

		#region ICopyable

		public void Copy(EngineSettingsBase source)
		{
			_hourOptions.Copy(source._hourOptions);
			_stockSelectionOptions.Copy(source._stockSelectionOptions);
			_stockParameters.Copy(source._stockParameters);
		}

		#endregion

		#region ICloneable

		public EngineSettingsBase Clone()
		{
			return new EngineSettingsBase(_hourOptions.Clone(), _stockSelectionOptions.Clone(), _stockParameters.Clone());
		}

		#endregion
	}
}

